home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 125
/
Freelog_MarsAvril2015_No125.iso
/
Musique
/
Quod Libet
/
quodlibet-3.3.0-installer.exe
/
bin
/
quodlibet
/
qltk
/
info.pyc
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2014-12-31
|
7KB
|
163 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.7)
import os
from gi.repository import Gtk, Gdk, Pango
from quodlibet import const
from quodlibet import qltk
from quodlibet.util.dprint import print_w
from quodlibet.qltk.properties import SongProperties
from quodlibet.qltk.information import Information
from quodlibet.qltk.ratingsmenu import RatingsMenuItem
from quodlibet.qltk.x import SeparatorMenuItem
from quodlibet.util import connect_obj, connect_destroy
from quodlibet.parse import XMLFromMarkupPattern
from quodlibet.qltk.textedit import PatternEdit
class SongInfo(Gtk.EventBox):
_pattern = "[span weight='bold' size='large']<title>[/span]<~length| (<~length>)><version|\n[small][b]<version>[/b][/small]><~people|\n%(people)s><album|\n[b]<album>[/b]<discnumber| - %(disc)s><discsubtitle| - [b]<discsubtitle>[/b]><tracknumber| - %(track)s>>" % {
'people': _('by %s') % '<~people>',
'disc': _('Disc %s') % '<discnumber>',
'track': _('Track %s') % '<tracknumber>' }
__PATTERN_FILENAME = os.path.join(const.USERDIR, 'songinfo')
def __init__(self, library, player):
super(SongInfo, self).__init__()
self.set_visible_window(False)
align = Gtk.Alignment(xscale = 0, xalign = 0, yscale = 0, yalign = 0)
label = Gtk.Label()
label.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
label.set_selectable(True)
align.add(label)
label.set_alignment(0, 0)
self._label = label
connect_destroy(library, 'changed', self._SongInfo__check_change, player)
connect_destroy(player, 'song-started', self._SongInfo__check_started)
connect_obj(label, 'populate-popup', self._SongInfo__menu, player, library)
self.connect('button-press-event', self._SongInfo__create_menu, player, library)
try:
self._pattern = file(self._SongInfo__PATTERN_FILENAME).read().rstrip()
except EnvironmentError:
pass
self._compiled = XMLFromMarkupPattern(self._pattern)
align.show_all()
self.add(align)
def __create_menu(self, widget, event, player, library):
button = event.button
if button == Gdk.BUTTON_SECONDARY:
menu = Gtk.Menu()
menu.attach_to_widget(widget, None)
self._SongInfo__menu(player, menu, library)
menu.popup(None, None, None, None, button, event.time)
return True
def __menu(self, player, menu, library):
try:
PlaylistMenu = PlaylistMenu
import quodlibet.browsers.playlists.menu
submenu = PlaylistMenu([
player.song], self) if player.song else Gtk.Menu()
except AttributeError:
e = None
print_w("Couldn't create songsmenu (%s)" % e)
b = qltk.MenuItem(_('Play_lists'), Gtk.STOCK_ADD)
if player.song is not None:
pass
b.set_sensitive(player.song.can_add)
b.set_submenu(submenu)
b.show_all()
sep = SeparatorMenuItem()
menu.prepend(sep)
sep.show()
menu.prepend(b)
sep = SeparatorMenuItem()
menu.prepend(sep)
sep.show()
rating = RatingsMenuItem([
player.song], library)
rating.set_sensitive(bool(player.song))
rating.show()
menu.prepend(rating)
item = qltk.MenuItem(_('_Edit Display...'), Gtk.STOCK_EDIT)
item.show()
connect_obj(item, 'activate', self._SongInfo__edit, player)
menu.append(item)
sep = SeparatorMenuItem()
menu.append(sep)
sep.show()
props = qltk.MenuItem(_('Edit _Tags'), Gtk.STOCK_PROPERTIES)
def song_properties_cb(menu_item):
window = SongProperties(library, [
player.info], self)
window.show()
props.connect('activate', song_properties_cb)
props.show()
props.set_sensitive(bool(player.song))
menu.append(props)
info = Gtk.ImageMenuItem(Gtk.STOCK_INFO, use_stock = True)
def information_cb(menu_item):
window = Information(library, [
player.info], self)
window.show()
info.connect('activate', information_cb)
info.show()
menu.append(info)
info.set_sensitive(bool(player.song))
def __edit(self, player):
editor = PatternEdit(self, SongInfo._pattern)
editor.text = self._pattern
connect_obj(editor.apply, 'clicked', self._SongInfo__set, editor, player)
editor.show()
def __set(self, edit, player):
self._pattern = edit.text.rstrip()
if self._pattern == SongInfo._pattern:
try:
os.unlink(self._SongInfo__PATTERN_FILENAME)
except OSError:
pass
pattern_file = file(os.path.join(const.USERDIR, 'songinfo'), 'w')
pattern_file.write(self._pattern + '\n')
pattern_file.close()
self._compiled = XMLFromMarkupPattern(self._pattern)
self._SongInfo__update_info(player)
def __check_change(self, library, songs, player):
if player.info in songs:
self._SongInfo__update_info(player)
def __check_started(self, player, song):
self._SongInfo__update_info(player)
def __update_info(self, player, last = None):
if not last:
pass
last = { }
text = "<span size='xx-large'>%s</span>" % _('Not playing') if player.info is None else self._compiled % player.info
if text not in last:
self._label.set_markup(text)
last.clear()
last[text] = True